package com.by.bean;

import com.by.common.group.ISave;
import com.by.common.group.IUpdate;
import com.mysql.cj.protocol.x.XMessage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@ApiModel("用户")
@Data
public class User {
    @Min(value = 1,message = "修改时用户id不能为空",groups = {IUpdate.class})
    @ApiModelProperty(name = "id",value="用户id",hidden = true,required = false)
    int id;

    @NotNull(message = "用户名不能为空！")
    /*@Length(min = 6,message = "用户名至少6位！",groups = {ISave.class, IUpdate.class})
    @ApiModelProperty(name = "username",value = "用户名",required = true)*/
    @ApiModelProperty(value = "用户名",required = true)
    String account;

    @NotNull(message = "密码不能为空！",groups = {ISave.class, IUpdate.class})
    @Pattern(regexp = "^[a-zA-Z0-9_]{8,12}$",message = "密码由字母、数字、下划线组成的8-12位",groups = {ISave.class, IUpdate.class})
    @ApiModelProperty(name = "password",value = "密码",required = true)
    String password;

    /*@Min(value = 18,message = "年龄最小18周岁")
    @Max(value = 45,message = "年龄不超45")
    int age;*/

    @ApiModelProperty(value = "用户类型",hidden = true)
    int type;
}






































